package com.itany.corejava.day06;

public class IntStack {

    private int[] data;
    private  int size;

    public IntStack(int max) {
        data=new int[max];
        size=0;
    }

    public IntStack() {
        this(10);//只能出现在构造方法的第一行
    }

    public boolean isFull(){
        return size==data.length;
    }

    public boolean isEmpty(){
        return size==0;
    }

    public void push(int i){
        if(isFull()){
            throw new RuntimeException("栈已满");
        }
        data[size++]=i;
    }

    public int pop(){
        if(isEmpty()){
            throw new RuntimeException("栈已空");
        }
        return data[--size];
    }

    public int getSize() {
        return size;
    }

}
